﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;

namespace Yoozoo.Gameplay.City
{

    [Serializable]
    public class PointEditorConfig
    {
        public CityPointType pointType;
        
        public GameObject hud;
        public Color color = Color.red;
        [Range(0.01f,5)]
        public float radius = 1.0f;
    }

    public enum PointPreviewMode
    {
        Sphere = 1,
        Wire = 2,
        Hud = 3,
    }
    
    [ExecuteAlways]
    public class CityPointEditorConfig : MonoBehaviour
    {
        public List<PointEditorConfig> PointEditorConfigs;

        [Header("是否显示点")]
        public bool preview = true;
        [Header("点的预览模式")]
        public PointPreviewMode previewMode = PointPreviewMode.Sphere;

        public Vector3 hudAngle = new Vector3(45, 0, 0);
        
        private static CityPointEditorConfig instance;

        public static CityPointEditorConfig Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = FindObjectOfType<CityPointEditorConfig>();
                }
                return instance;
            }
        }

        public static PointEditorConfig GetConfig(CityPointType pointType)
        {
            foreach (var config in Instance.PointEditorConfigs)
            {
                if (config.pointType == pointType)
                {
                    return config;
                }
            }

            return null;
        }
    }
}